Hi Folks,
int i
AttrType at = find(current Module,"level2tran")
if(!null at && at.type == attrEnumeration)
{
int offset = null
int length = null
bool matchCase = true
bool reverse = true
for (i = 0; i < at.size; i++)
{
string s = at.strings[i]
string sub = "H."
if (!findPlainText (s, sub, offset, length, matchCase, reverse))
{
print (at.strings[i]) "\t"
//at = modify(at,"level2tran",new_strings,new_values,new_colors,new_descs,new_map,errMess)
}
}
}
mwilliamson - Fri Oct 02 05:09:08 EDT 2009 |
Re: Deleting enumeration value
I think this may be what you are looking for....
bool removeEnumeration (AttrType at, string sRemVal) {
bool bExists = false
string sError = ""
// Load Definition of provided Attribute Type
if ( at != null ) {
string atType = at.name
string an = sRemVal
string listNew[at.size-1 ] = null
int values[at.size-1] = null
int colors[at.size-1] = null
int mapping[at.size-1] = null
int i = 0
// Check if provided Enumeration exists in Attribute Type Definition
for (i=0; i<at.size; i++) {
string sEnumVal = at.strings[i]
if ( sEnumVal == sRemVal ) {
bExists = true
}
}
// If Enumeration exists then Modify Attribute Type Definition
if (bExists) {
int j = 0
for (i=0; i<at.size; i++) {
string sEnumVal = at.strings[i]
if ( sEnumVal != sRemVal ) {
listNew[j] = sEnumVal
values[j] = 0
colors[j] = 0
mapping[j] = j
j++
}
}
noError()
modify(at, atType, listNew, values, colors, mapping, null)
sError = lastError()
}
}
// Return True is Modify was successful, else False
return ((sError == "") && ( !bExists ))
}
Attachments attachment_14301305_RemoveEnumeration.dxl |
Re: Deleting enumeration value roybond - Fri Oct 02 09:06:02 EDT 2009
I think this may be what you are looking for....
bool removeEnumeration (AttrType at, string sRemVal) {
bool bExists = false
string sError = ""
// Load Definition of provided Attribute Type
if ( at != null ) {
string atType = at.name
string an = sRemVal
string listNew[at.size-1 ] = null
int values[at.size-1] = null
int colors[at.size-1] = null
int mapping[at.size-1] = null
int i = 0
// Check if provided Enumeration exists in Attribute Type Definition
for (i=0; i<at.size; i++) {
string sEnumVal = at.strings[i]
if ( sEnumVal == sRemVal ) {
bExists = true
}
}
// If Enumeration exists then Modify Attribute Type Definition
if (bExists) {
int j = 0
for (i=0; i<at.size; i++) {
string sEnumVal = at.strings[i]
if ( sEnumVal != sRemVal ) {
listNew[j] = sEnumVal
values[j] = 0
colors[j] = 0
mapping[j] = j
j++
}
}
noError()
modify(at, atType, listNew, values, colors, mapping, null)
sError = lastError()
}
}
// Return True is Modify was successful, else False
return ((sError == "") && ( !bExists ))
}
I think you mean...
mapping[j] = i // '= i', not '= j'
Also, using 'null' for an unused ErrMess gives me the hebegebes. I'd do this:
string ErrMess = ""
modify(at, atType, listNew, values, colors, mapping, ErrMess)
then ignore ErrMess
Skip skpRemoveEnums = createString()
void RemoveEnumsPrepare()
{ delete(skpRemoveEnums)
skpRemoveEnums = createString()
}
void RemoveEnumsAddEnum(string Enum)
{ put(skpRemoveEnums, Enum, Enum)
}
void RemoveEnumsProceed(AttrType at)
{ for i -> at.size
if this actual enum is in the Skip
then CountToBeRemoved++
else remove that enum from Skip, and report it
Declare vectors [at.size-CountToBeRemoved]
for i -> at.size
if this actual Enum is in the Skip
then do nothing
else update your vectors, using mapping[j] = i
}
Calling scripts would Prepare, add list of Enums, then Proceed.
|
Re: Deleting enumeration value Nice to see I'm not the only one who lines up open braces vertical with the corresponding closing brace. For me its SOOOooooo much easier to read. And debug.
|
Re: Deleting enumeration value llandale - Fri Oct 02 10:41:20 EDT 2009
Hi Roy and Louie.
AttrType at = find(current Module,"level2tran")
if(!null at && at.type == attrEnumeration)
{
string atType = at.name
string listNew[at.size-1 ] = null
int values[at.size-1] = null
int colors[at.size-1] = null
int mapping[at.size-1] = null
int i = 0
int offset = null
int length = null
bool matchCase = true
bool reverse = true
int j = 0
for (i = 0; i < at.size; i++)
{
string s = at.strings[i]
string sub = "I."
if (!findPlainText (s, sub, offset, length, matchCase, reverse))
{
listNew[j] = s
values[j] = 0
colors[j] = 0
mapping[j] = i
j++
}
modify(at, atType, listNew, values, colors,mapping, null)
}
}
|
Re: Deleting enumeration value llandale - Fri Oct 02 10:41:20 EDT 2009
Mark |
Re: Deleting enumeration value mwilliamson - Fri Oct 02 11:55:27 EDT 2009
Hi Roy and Louie.
AttrType at = find(current Module,"level2tran")
if(!null at && at.type == attrEnumeration)
{
string atType = at.name
string listNew[at.size-1 ] = null
int values[at.size-1] = null
int colors[at.size-1] = null
int mapping[at.size-1] = null
int i = 0
int offset = null
int length = null
bool matchCase = true
bool reverse = true
int j = 0
for (i = 0; i < at.size; i++)
{
string s = at.strings[i]
string sub = "I."
if (!findPlainText (s, sub, offset, length, matchCase, reverse))
{
listNew[j] = s
values[j] = 0
colors[j] = 0
mapping[j] = i
j++
}
modify(at, atType, listNew, values, colors,mapping, null)
}
}
I'd also go ahead and read the Values and Colors, and transfer them to the new vectors: values[j] = at.values[i] colors[j] = at.colors[i]
|
Re: Deleting enumeration value llandale - Mon Oct 05 18:39:27 EDT 2009
I've managed to get myself completely confused with the vector/pointers and unfotunately cannot waste any more time on this "helper script" I could have completed the task laboriously through the GUI in the time I have spent trying to get this "simple" script working. I will come back to it later for my own sanity Cheers Mark |